<template>
  <BasicModal v-bind="$attrs" @register="registerModal" :defaultFullscreen="true" :destroyOnClose="true" title="导入安管系统数据" :showCancelBtn="false" :showOkBtn="false" :width="1200">
    <!--引用表格-->
    <div class="table-content table-width">
      <BasicTable @register="registerCustomTable">
        <!--插槽:table标题-->
        <template #tableTitle>
          <a-button type="primary">导入已选57条数据</a-button>
        </template>
        <template #action="{ record }">
          <TableAction :actions="getTableAction(record)" />
        </template>
      </BasicTable>
    </div>
  </BasicModal>
</template>

<script lang="ts" name="com.hzzenith.km.emp-hubTeamAdd" setup>
import { ref } from 'vue';
import { BasicTable } from '/@/components/Table';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import { systemForm, systemColumns } from './HubTeamResultWork.data';
import { useMessage } from '/@/hooks/web/useMessage';
import { list } from './HubTeamResultWork.api';
import dayjs from 'dayjs';

// 轻提醒
const { createMessage: $message } = useMessage();
// Emits声明
const emit = defineEmits(['register', 'success']);

const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
  console.log('data', data);
  reload({
    searchInfo: {
      ...data,
      // orgCode: data.orgCode,
      // periodCode: data.periodCode,
    },
  });
  // reload();
});

//注册table数据
const { prefixCls, tableContext, onImportXls } = useListPage({
  tableProps: {
    // title: 'hub_team_add',
    api: list,
    columns: systemColumns,
    canResize: false,
    // dataSource: [],
    showIndexColumn: true,
    showActionColumn: false,
    rowKey: 'id',
    beforeFetch: (params) => {
      return Object.assign(params, {});
    }, //表格和查询条件同步更新的方法
    formConfig: {
      //labelWidth: 120,
      schemas: systemForm,
      autoSubmitOnEnter: true,
      showAdvancedButton: false,
      fieldMapToNumber: [],
      fieldMapToTime: [],
      // resetFunc: handleCancel,
    },
    immediate: false, // 班组表格放到orgCode拿到值之后再加载 false不会立即加载,reload()之后再加载
  },
});

const [registerCustomTable, { getForm, reload, getDataSource, setColumns, getColumns }] = tableContext;

function getTableAction(record) {
  return [
    {
      label: '查看详情',
      onClick: handleDetail.bind(null, record),
    },
  ];
}

const handleDetail = () => { };
</script>

<style scoped lang="less">
.treeBox {
  margin: 10px 0 0 8px;
  background-color: white;
  height: calc(100% - 20px);
  width: 270px;
}

.table-width {
  width: calc(100% - 350px);
}

.treeTitle {
  margin-top: 10px;
  background-color: #009688;
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: #fff;
  font-size: 20px;
}
</style>
